//
//  W_BasicViewController.m
//  Go!
//
//  Created by 凌風 on 16/7/15.
//  Copyright © 2016年 凌风. All rights reserved.
//

#import "W_BasicViewController.h"

@interface W_BasicViewController ()


@property (nonatomic, strong) UIButton *dismissBtn; /**< 控制器消失按钮 */
@property (nonatomic, strong) UILabel_Font *titleLabel; /**< 自定义导航栏标题标签 */

@end

@implementation W_BasicViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // 设置背景色
    self.view.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1];

    [self.view addSubview:self.topView];
    [self.view addSubview:self.dismissBtn];
}

#pragma mark -- 监听事件回调方法
- (void)respondsToDismissBtn:(UIButton *)sender {
    
    [self dismissViewControllerAnimated:true completion:nil];
    
}

#pragma mark -- Setter
- (void)setTopTitle:(NSString *)topTitle {
    if (_topTitle != topTitle) {
        _topTitle = topTitle;
        
        self.titleLabel.text = topTitle;
    }
}
#pragma mark -- Getter
- (UIView *)topView {
    if (!_topView) {
        _topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenW, 64)];
        _topView.backgroundColor = [UIColor whiteColor];
        
        [_topView addSubview:self.titleLabel];
    }
    
    return _topView;
}

- (UIButton *)dismissBtn {
    if (!_dismissBtn) {
        _dismissBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _dismissBtn.frame = CGRectMake(Size_W(8), 20 + Size_H(44 - 20) / 2, Size_W(20), Size_H(20));
        [_dismissBtn setImage:[UIImage imageNamed:@"取消登录.png"] forState:UIControlStateNormal];
        
        [_dismissBtn addTarget:self action:@selector(respondsToDismissBtn:) forControlEvents:UIControlEventTouchUpInside];
    }
    
    return _dismissBtn;
}

- (UILabel_Font *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel_Font alloc] initWithFrame:CGRectMake(0, 20, ScreenW, 44)];
        _titleLabel.font = [UIFont boldSystemFontOfSize:Font(20)];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        
    }
    
    return _titleLabel;
}

@end
